public void levelOrder(TreeNode root) {
        if(root == null) {
        return;
        }
        Queue<TreeNode> queue = new LinkedList<>();
        queue.offer(root);
        while (!queue.isEmpty()) {
        TreeNode cur = queue.poll();
        System.out.print(cur.val+" ");
        if(cur.left != null) {
        queue.offer(cur.left);
        }
        if(cur.right != null) {
        queue.offer(cur.right);
        }
        }
        }

//把每一层 放到一个List里面
public List<List<Character>> levelOrder2(TreeNode root) {
        List<List<Character>> retList = new ArrayList<>();
        if(root == null) {
        return retList;
        }
        Queue<TreeNode> queue = new LinkedList<>();
        queue.offer(root);
        while (!queue.isEmpty()) {
        //拿当前队列的节点个数来看的
        int size = queue.size();//2
        List<Character> list = new ArrayList<>();
        while (size != 0) {
        TreeNode cur = queue.poll();
        list.add(cur.val);
        size--;//0
        if(cur.left != null) {
        queue.offer(cur.left);
        }
        if(cur.right != null) {
        queue.offer(cur.right);
        }
        }
        retList.add(list);
        }
        return retList;
        }